home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 11⁄3⁄89 / 0032-Re[2] Failure Handli-Nov89 < prev   
Encoding:
Text File  |  1989-11-03  |  1.6 KB  |  41 lines  |  [TEXT/GEOL]

  1. Item    6374083                         3-Nov-89        09:24
  2.  
  3. From:   PASCOE1                         Pascoe, Geoff
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. Sub:    Re Re Failure Handling
  8.  
  9. Curtis and Larry
  10.  
  11. Freeing objects in case of failures in initialization methods is the most
  12. common use of failure handlers, but there are other uses-
  13.  
  14.     • Freeing of any type of memory
  15.     • Unlocking of handles
  16.     • Closing files
  17.     • other stuff
  18.  
  19. Basically, you need to use failure handlers anytime you need something 'like'
  20. an atomic action.  That is, do it all or don't do anything.  Of course,
  21. sometimes you can't tell that an action will fail in the middle of an action,
  22. or at least it would be inconvenient to preflight everything.  So, you set up a
  23. failure handler to undo everything that needs to be 'nullified' up to the point
  24. (closing files, network connections, freeing memory, etc.) where the failure
  25. happened.
  26.  
  27. This all seems kind of complicated and requires a lot of thought (see my reply
  28. to your TCellSelectCommand bug).  I find that in my own work I tend to put in
  29. all the failure handlers last.  You have to get into a special kind of frame of
  30. mind, but once you do you can really make a lot of progress quickly.
  31.  
  32. I happen to think this one of the really nice features of MacApp.  If used
  33. properly it can make your application orders of magnitude more robust.
  34.  
  35. Geoff
  36.  
  37. P.S. Don't forget to test the failure handlers.  The MacApp debugger has some
  38. facilities to invoke failure handlers to help you in this task.  It's easy to
  39. make mistakes in this stuff.
  40.  
  41.